package cn.itcast.service.impl;

import cn.itcast.dao.cargo.PackingDao;
import cn.itcast.domain.cargo.Contract;
import cn.itcast.domain.cargo.ContractExample;
import cn.itcast.domain.cargo.Packing;
import cn.itcast.domain.cargo.PackingExample;
import cn.itcast.service.PackingService;
import com.alibaba.dubbo.config.annotation.Service;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;
import java.util.UUID;

@Service
public class PackingServiceImpl implements PackingService {
    @Autowired
    private PackingDao packingDao;

    @Override
    public PageInfo findAll(PackingExample packingExample, int pageNum, int pageSize) {
        PageHelper.startPage(pageNum, pageSize);
        List<Packing> packings = packingDao.selectByExample(packingExample);
        PageInfo pb = new PageInfo<>(packings);
        return pb;
    }

    @Override
    public void save(Packing packing) {
        packing.setState(0);
        packingDao.insert(packing);
    }

    @Override
    public Packing findById(String id) {
        Packing packing = packingDao.selectByPrimaryKey(id);
        return packing;
    }

    @Override
    public void delete(String id) {
        packingDao.deleteByPrimaryKey(id);
    }

    @Override
    public void updateByDoMain(Packing packing) {
        packingDao.updateByPrimaryKeySelective(packing);
    }

}
